# -*- conding:UTF-8 -*-

'''
@ Project: one-group
@ File: jwt_auth.py
@ Author: 孙博
@ Date：2022/6/9 14:23

'''
from flask import g, request
from util.jwt_utils import check_token


def jwt_authorization():
    token = request.headers.get('Authorization')
    print('header里面的token', token)
    if token:
        try:
            payload = check_token(token)
            print('验证的payload-------------》', payload)
            g.user_id = payload.get('id')
            print('g.user_id', g.user_id)
        except Exception as e:
            print('', e)
    else:
        print('未登录')


# def jwt_authorization():
#     token = request.headers.get('Authorization')
#     print('请求头中的token>>>>', token)
#     if token:
#         payload = check_token(token)
#         if payload:
#             g.user_id = payload['id']
#             print('g.user_id>>>>>', g.user_id)

